{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#用核PCA实现非线性降维"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由于大多数统计方法最开始都是线性的，所以，想解决非线性问题，就需要做一些调整。PCA也是一种线性变换。本主题将首先介绍它的非线性形式，然后介绍如何降维。\n",
    "\n",
    "<!-- TEASER_END -->"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Getting ready"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果数据都是线性的，生活得多容易啊，可惜现实并非如此。核主成分分析（Kernel PCA）可以处理非线性问题。数据先通过核函数（kernel function）转换成一个新空间，然后再用PCA处理。\n",
    "\n",
    "要理解核函数之前，建议先尝试如何生成一个能够通过核PCA里的核函数线性分割的数据集。下面我们用余弦核（cosine kernel）演示。这个主题比前面的主题多一些理论。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##How to do it..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "余弦核可以用来比例样本空间中两个样本向量的夹角。当向量的大小（magnitude）用传统的距离度量不合适的时候，余弦核就有用了。\n",
    "\n",
    "向量夹角的余弦公式如下：\n",
    "\n",
    "$$cos(\\theta)=\\frac {A \\cdot B} \n",
    "{{\\begin{Vmatrix}\n",
    "A\n",
    "\\end{Vmatrix}}\n",
    "{\\begin{Vmatrix}\n",
    "B\n",
    "\\end{Vmatrix}}}\n",
    "$$\n",
    "\n",
    "向量$A$和$B$夹角的余弦是两向量点积除以两个向量各自的L2范数。向量$A$和$B$的大小不会影响余弦值。\n",
    "\n",
    "让我们生成一些数据来演示一下用法。首先，我们假设有两个不同的过程数据（process），称为$A$和$B$："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "A1_mean = [1, 1]\n",
    "A1_cov = [[2, .99], [1, 1]]\n",
    "A1 = np.random.multivariate_normal(A1_mean, A1_cov, 50)\n",
    "A2_mean = [5, 5]\n",
    "A2_cov = [[2, .99], [1, 1]]\n",
    "A2 = np.random.multivariate_normal(A2_mean, A2_cov, 50)\n",
    "A = np.vstack((A1, A2))\n",
    "B_mean = [5, 0]\n",
    "B_cov = [[.5, -1], [.9, -.5]]\n",
    "B = np.random.multivariate_normal(B_mean, B_cov, 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x73cd128>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAk8AAAJbCAYAAAD9gHDjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XuQZNldH/jv6WlG9CAL6J6NxYIxUshmxQohZtASMiti\nekE9rZUlsTK7XljbLOD1P8i8uhfQuHqlQTtlsL0zfrH7BwZsEQhjVkIE2lCoZ3h0E7PIGMNYQq8F\ngSQkwQR0Ny9bY0aiz/5xs9TV1VlVeStvZt7H5xORUVmZtzJP3srHN8/53XNKrTUAACzm2KYbAAAw\nJMITAEALwhMAQAvCEwBAC8ITAEALwhMAQAvCEwBAC8ITAEALwhOwEqWUf1lK+d833Q6ArglPwKrU\n2QlgVI5vugHA+pRS7kjySK31xeu6y0Pa86VJXp/kRJI3zi5+fpI/rLU+cOQ7LeV4rfWTR/17gIPo\neYJp+ZYkf7mUctu8K0sprymlfKCU8sellPeUUv67Pdd/qJRyvpTyzlLKH5ZSfryU8rTZdXeXUn51\n9rc/nuTTD2tMrfVXkvxJkv+j1vpDtdYfSnIhyf82C3p72/ehWRvfU0q5Vkr54V33/6FSyneVUt6V\n5E9KKcdKKV9YSrlUSvmDUsq7Symv2HN7d5VSfrKU8nullCullH82u/yZp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7TK9MMGb1u9+Zd3e+UHbDPX7Frm60kT9Vaf2yDTR0z\nwxcbUkp5epI3Jfm2WQ8UK1JKeXmS36u1Ph7v3+tyPMk9Sf6vWus9Sf5jktdstknjVkp5TpJvT/Ks\nNL3ZTy+l/PV52x44w3gbtdYz+zTmi9Ik6HeWUpJm+OhXSim3TKhJO/vt8x2llG9I083+VWtp0DR9\nLMldu36/K03vEytUSvm0JG9O8qO11p/adHsm4MuTvLKU8rIkn57kGaWUH6m1fv2G2zVmH00zYvPL\ns9/fFOFp1V6Y5BdrrVeTpJTyk2me+2/cu+HKh+1qre+utf7ntdZn11qfneYJcY/gtFqllJem6WL/\n6lrrf9p0e0bs3yX5S6WUZ5VSbk/yPyb56Q23adRK8y3sh5K8t9b6jzfdnimotf7dWutds/fwr03y\nc4LTatVan0jykVLKF8wuekmS92ywSVPw/iQvKqWcmL3PvCTNARK36KznqQXDHOvxz5LcnuTRWY/f\nO2qt37zZJo1PrfWTpZS/k+RimiMzfqjW6oiY1fqvk/yNJO8qpTw+u+z+WuvbN9imqfE+vh7fkuSN\nsy9mv5nkGzfcnlGrtb6zlPIjab4UX0/yq0l+YN62JskEAGhhrZNkAgAMnfAEANCC8AQA0ILwBADQ\ngvAEANCC8AQA0ILwBADQgvAEANDC/w+alB3P7q2fpwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7789cf8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "f = plt.figure(figsize=(10, 10))\n",
    "ax = f.add_subplot(111)\n",
    "ax.set_title(\"$A$ and $B$ processes\")\n",
    "ax.scatter(A[:, 0], A[:, 1], color='r')\n",
    "ax.scatter(A2[:, 0], A2[:, 1], color='r')\n",
    "ax.scatter(B[:, 0], B[:, 1], color='b')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "上图看起来明显是两个不同的过程数据，但是用一超平面分割它们很难。因此，我们用前面介绍带余弦核的核PCA来处理："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.decomposition import KernelPCA\n",
    "kpca = KernelPCA(kernel='cosine', n_components=1)\n",
    "AB = np.vstack((A, B))\n",
    "AB_transformed = kpca.fit_transform(AB)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmoAAAEKCAYAAACiznm4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XuYHVWd7vH31925dIfcAyHkYgwEFPCCImQUjy06EECI\nDCogKAYegYeDjoMzEnTOGAEF9BEZRQERER0lwOhkAgQkKi0cdeCAOANCgACRQCCAJCTknvR7/ljV\n9O7du3dfdpJeTb6f56mnd+29VtWqWlW7365bh20BAAAgP3X93QAAAABURlADAADIFEENAAAgUwQ1\nAACATBHUAAAAMkVQAwAAyBRBDUCfRMRDEfG/+rsdA01EnBcRV/d3O0pFxJqImNrf7QDQGUEN2AlE\nxMcj4r7iF/LyiFgYEe+pZZq297d917ZqY5uI+FFEXFAyvl9EPBcR5xTjSyNiXbEsz0fEtRExrKT8\n4RFxV0SsjogXIqIlIo4um0dzRLRGxBe6acugiPj3iHiqKP++bsq3RMT6Yt6vFOv83IgY3FbG9kW2\nP93b9bI92R5ue2l/twNAZwQ14HWuCDjfknShpN0kTZb0XUnH9Ge7qnAxKCIOkPQbSefbvrTk8w/Z\nHi7pHZIOlPTPRfmPSLpR0o8kTbS9m6R/kdQhqEk6RdJDkj7Zg/bcJelkSc+3taubtv9v2yMk7S7p\n85JOkLSwB/MBgE4IasDrWESMlPQVSWfZnm97ve2ttm+1fW5RZkhEXBYRzxbDt9qOAEXEuIi4JSJW\nRsRfI+KukmkvjYhDi9dzI+LGiL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2m8Vzx88WI+A+lQ8j8stgBtkH/PStpcsn4ZHX8d2LY\nTqr1XXFh7O4lD7d+oYtpsO/loyf7UnmZScV76H/d9p/tNSWvb4uI70XEGNsv76A2om96vd8N1FOf\nFc/LR0RTRAwvXg+TdJjSRezIS1fXVbz2gOSIGKz0gOQFO65Z6ELbw62lLh5uzb6XnZ7sSwskfVJ6\n7b/IrCo5xY3+1W3/RcT4iIji9UFKj9sipOWv1/vdgAlqXT0gt/QBu0qnbu6OiD9JukfSLbbv6J8W\no1RP+q/aA5LRr7p9uLXY97LS1b4UEWdExBlFmYWSnoyIJZKuknRWvzUYHfSk/yR9RNKDxT53maQT\n+qe1KBUR10v6vaR9ImJZRJxa637HA28BAAAyNWCOqAEAAOxsCGoAAACZIqgBAABkiqAGAACQKYIa\nAABApghqAAAAmSKoAQAAZIqgBgAAkKn/D17yHzKMGv9BAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7b97b38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "A_color = np.array(['r']*len(B))\n",
    "B_color = np.array(['b']*len(B))\n",
    "colors = np.hstack((A_color, B_color))\n",
    "f = plt.figure(figsize=(10, 4))\n",
    "ax = f.add_subplot(111)\n",
    "ax.set_title(\"Cosine KPCA 1 Dimension\")\n",
    "ax.scatter(AB_transformed, np.zeros_like(AB_transformed), color=colors);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "用带余弦核的核PCA处理后，数据集变成了一维。如果用PCA处理就是这样："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7c764a8>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmYAAAEKCAYAAAC48pk2AAAABHNCSVQICAg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Xn\nvK13jqSb8z+qnpV0ZncFq3ooEwAA4K9JtQ9lAgAA/NUgmAEAACSCYAYAAJAIghkAAEAiCGYAAACJ\nIJgBAAAkgmAGAACQCIIZAABAIv4/EdQY72KN2oEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xa3db898>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.decomposition import PCA\n",
    "pca = PCA(1)\n",
    "AB_transformed_Reg = pca.fit_transform(AB)\n",
    "f = plt.figure(figsize=(10, 4))\n",
    "ax = f.add_subplot(111)\n",
    "ax.set_title(\"PCA 1 Dimension\")\n",
    "ax.scatter(AB_transformed_Reg, np.zeros_like(AB_transformed_Reg), color=colors)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "很明显，核PCA降维效果更好。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##How it works..."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "scikit-learn提供了几种像余弦核那样的核函数，也可以写自己的核函数。默认的函数有：\n",
    "\n",
    "- 线性函数（linear）（默认值）\n",
    "- 多项式函数（poly）\n",
    "- 径向基函数（rbf，radial basis function）\n",
    "- S形函数（sigmoid）\n",
    "- 余弦函数（cosine）\n",
    "- 用户自定义函数（precomputed）\n",
    "\n",
    "还有一些因素会影响核函数的选择。例如，`degree`参数可以设置`poly`，`rbf`和`sigmoid `核函数的角度；而`gamma`会影响`rbf`和`poly`核，更多详情请查看[`KernelPCA`文档](http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.KernelPCA.html)。\n",
    "\n",
    "后面关于支持向量机（SVM）的主题中将会进一步介绍`rbf`核函数。\n",
    "\n",
    "需要注意的是：核函数处理非线性分离效果很好，但是一不小心就可能导致拟合过度。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
